<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src='./lib/jquery-3.1.0.min.js'></script>
</head>
<body>
     <button>获取天气预报</button>
     <hr>
     <div id='showData'></div>
  <script>
      $("button").click(()=>{
         $.ajax({
            type:"get",
            url:"https://restapi.amap.com/v3/weather/weatherInfo",
            data:{
                "key":"4fa1a165ff39d183009302c80310ee1b",
                "city":"自贡",
                "extensions":"base",
                "output":"JSON"
            },
            dataType:"jsonp",
            success:(data)=>{
            //console.log(data);
            $("#showData").html(
              `
                省份：${data.lives[0].province},
                城市：${data.lives[0].city},
                实时温度：${data.lives[0].temperature}℃,
                天气现象：${data.lives[0].weather}
                最近的更新时间：${data.lives[0].reporttime}
              `
            )
            }
         }) 
      })
  </script>   
</body>
</html>